﻿#pragma once
#include "scene.h"
//#include "renderModel.h"
#include "Viewport.h"
#include "Models_logo.h"
#include "PlayerObject.h"
#include "MuNetConnect.h"
#include "DlgServerList.h"
#include "DlgLogin.h"
#include "GameObjectList.h"

//#include "TextureRenderData.h"
//#include "TextureRenderHandle.h"

class SceneLogin;
class SceneLogin :
    public Scene, protected MuNetConnect::Listener
{
public:
	SceneLogin();
	~SceneLogin();

	CREATE_FUNC(SceneLogin)

	virtual bool Init();
	virtual void Update();
	virtual void window_size_callback(int width, int height) override;

private:
	TextureManager m_texMgr;
	Camera m_camera;
	Camera m_camera2;
	GameObjectList m_gameObjList1;
	Viewport m_viewport1;
	Viewport m_viewport2;
	Models_logo m_mdls_logo;
	PlayerObject *faShi;
	PlayerObject *zhanShi;
	PlayerObject *gongJianShou;

	CEGUI::Window *m_wnd_root;
	DlgServerList m_dlgServerList;
	DlgLogin m_dlgLogin;

	//CTextureRenderData m_texData1;
	//CTextureRenderHandle_matrix m_texHandle_flare01[4];

	//Model m_mdl_face[4];	//法师头像,战士,弓箭手,魔剑士
	//Model m_mdl_logo[5];	//海面,船尾波浪,"MU"字体logo,日出位置的一个动态模型,选择人物界面的背景
	//Model m_mdl_ship1;		//船
	//
	//RenderModel m_obj_logo01;	//海面
	////RenderInfo m_ri_logo01;
	//float *m_texOffset_logo01;
	//
	//RenderModel m_obj_ship1;	//船
	//RenderInfo m_ri_ship1[3];
	//
	//RenderModel m_obj_logo02;	//船尾波浪
	//RenderInfo m_ri_logo02[2];
	//float *m_texOffset_logo02;
	//
	//RenderModel m_obj_logo04;	//日出位置的一个动态模型
	//
	//RenderModel m_obj_logo03;	//"MU"字体logo

	//RenderModel m_ply_zs;
	//void DispatchPacket(MuNetworkPacket &netPack);
	void DispatchPacket(BYTE *data, int len);

	void cb_AfterConnect_cs(bool f);
	void cb_AfterConnect_gs(bool f);
	void cb_AfterClose_cs();
	void cb_AfterClose_gs();
	void cb_selectLine(int groupIndex, int lineIndex);
	void cb_login(char *username, char *password);

	void OnServerList(MuPack::ServerList *lst);
	void OnServerAddr(MuPack::ServerAddr *addr);
	void OnGameObjIdAndVersion(MuPack::GameObjIdAndVersion *idver);
	void OnLogin(int state);

    // 继承 MuNetConnect::Listener
    virtual void on_cs_firstResponse() override;
    virtual void on_cs_serverList(MuPack::ServerList* serverList) override;
    virtual void on_cs_serverAddr(MuPack::ServerAddr* serverAddr) override;
    virtual void on_gs_connect(bool status) override;
    virtual void on_gs_loginResult(u_char status) override;

    virtual void on_cs_close() override;
    virtual void on_gs_close() override;
};

